<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, height=device-height">
    <title>狼吃羊</title>
    <link rel="stylesheet" type="text/css" href="css/nonet.css">
    <script type="text/javascript">
        var cssEl = document.createElement('style');
        document.documentElement.firstElementChild.appendChild(cssEl);
        function setPxPerRem(){
            var dpr = 1;
            //把viewport分成10份的rem，html标签的font-size设置为1rem的大小;
            var pxPerRem = document.documentElement.clientWidth * dpr / 10;
            cssEl.innerHTML = 'html{font-size:' + pxPerRem + 'px!important;}';
        }
        setPxPerRem();
    </script>
    <script type="text/javascript" src="board.js"></script>
    <script type="text/javascript" src="position.js"></script>

</head>
<body>

<div style="text-align:center;white-space:nowrap">
    <div id="container"></div>
    <div id="sheepText" style="position: absolute; top: 49px; left: 20px;font-size:25px; color: sienna" align="left">欢迎来到狼吃羊 </div>
</div>
<div id="startGame">开始游戏</div>
<div id="setting">设置</div>
<script >
    "use strict";
    var board = new Board(container, sheepText,"images/");	// 创建棋盘
    var sheeps=23
    var lesshheeps=12
    var start=false
    function startGameA() {
        startGame.innerText="重新开始"
        if(start){
            board.endGame()
        }
        board.startGame(sheeps,lesshheeps)
        start=true
    }
    function prom()
    {
        var s=parseInt(prompt("请输入初始羊的数目:","23"));//将输入的内容赋给变量 name ，
        //这里需要注意的是，prompt有两个参数，前面是提示的话，后面是当对话框出来后，

        if(s)//如果返回的有内容
        {
            if(isNaN(s)){
                alert("请输入合法数字")
                return
            }
            if(s<8){
                alert("请输入最少8只羊")
                return
            }
            sheeps=s
           startGameA()
        }
    }

    document.getElementById("startGame").onclick = function () {
        startGameA()
    };
    document.getElementById("setting").onclick = function () {
        //弹出一个输入框，输入一段文字，可以提交
         prom()
    };


</script>
</body>
</html>